package cs236703.winter2013.hw4.tests;

import cs236703.winter2013.hw4.solution.JBefore;
import cs236703.winter2013.hw4.solution.JCore;
import cs236703.winter2013.hw4.solution.JSetup;
import cs236703.winter2013.hw4.solution.JTest;
import cs236703.winter2013.hw4.solution.JTestClass;

public @JTestClass class MyDerivedClass extends MyClass {
	
	private boolean test2, beforeOverride2;
	
	@Override
	protected @JBefore({"test1", "test2", "override"}) void beforeOverride() {
		if(!(setup1 && setup2 && setup3) || beforeOverride)
			faulty = "beforeOverride";
		beforeOverride = true;
		loc = "derived";
	}
	
	private @JBefore({"override"}) void beforeOverride2() {
		if(!(setup1 && setup2 && setup3) || beforeOverride2)
			faulty = "beforeOverride2";
		beforeOverride2 = true;
	}
	
	private @JSetup void setup3() {
		usingDerived = true;
		setup3 = true;
	}
	
	@Override
	public @JTest void override() {
		if(!beforeOverride || !beforeOverride2 || !before1 || override || !faulty.isEmpty()) {
			String reason = faulty;
			faulty = "";
			JCore.assertEquals("override derived reason: " + reason, false);
		}
		JCore.assertEquals("derived", loc);
		override = true;
		before1 = beforeOverride = beforeOverride2 = false;
	}
	
	private @JTest void test2() {
		if(!beforeOverride || test2 || !faulty.isEmpty()) {
			String reason = faulty;
			faulty = "";
			JCore.assertEquals("test2 reason: " + reason, false);
		}
		test2 = true;
		beforeOverride = false;
	}
}
